package com.nervenets.web.controller.type;

import com.nervenets.web.hibernate.domain.Type;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
public class TypeModel implements Serializable {
    private long typeId;
    private long parentId;
    private String logo;
    private String name;
    private boolean enable;
    private int queue;
    private List<TypeModel> children = new ArrayList<>();

    public TypeModel(Type type) {
        this.typeId = type.getId();
        this.parentId = type.getParentId();
        this.logo = type.getLogo();
        this.name = type.getName();
        this.enable = type.isEnable();
        this.queue = type.getQueue();
    }

    public void addChild(TypeModel typeModel) {
        if (null == this.children) this.children = new ArrayList<>();
        this.children.add(typeModel);
    }
}
